import { Component, OnDestroy, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { InformationService } from 'src/app/service/information.service';
import { TSGGInfos, XXGGInfos } from 'src/assets/mock/common/common';

@Component({
  selector: 'app-image-card',
  templateUrl: './image-card.component.html',
  styleUrls: ['./image-card.component.scss']
})
export class ImageCardComponent implements OnInit {

  constructor(
    private information: InformationService,
    private router: Router
  ) { }

  ngOnInit(): void {
    this.getTSGGInfos()
    this.getXXGGInfos()
  }

  TSGGInfos: any = []
  getTSGGInfos(){
    this.information._getContentList('water_quality_notice', 1, 3).subscribe({
      next: res => {
        if(res && res.data){
          // res.data.length = 3
          this.TSGGInfos = res.data
        }
      }
    })
  }

  XXGGInfos: any = []
  getXXGGInfos(){
    this.information._getContentList('GROUP_news', 1, 2).subscribe({
      next: res => {
        if(res && res.data){
          this.XXGGInfos = res.data
        }
      }
    })
  }

  goDetail(item: any){
    // this.information.informationDetail = item
    this.router.navigate(['/information/detail'], { queryParams: { id: item.id } })
  }

}
